<template>
	<view class="safe-area-inset-bottom">
		<!-- 个人添加 -->
		<!-- 搜索框 -->
		<view class="swip_header">
		<view class="slot-box">
			<view style="width: 100%;">
				<uni-search-bar v-model="queryParams.params.findApi" type="text" @confirm="handleQuery" @input="handleQuery" placeholder="请输入名字" />
			</view>
		</view>
		</view>
        <view class="scroll_view">
		  <view v-if="staffList.length !== 0">
			<view class="table_view" @click="selectChange(item)" v-for="(item, index) in staffList" :key="index">
				<span style="width: 30%;">
				<i class="iconfont grayIcon" style="margin:0 10rpx 0 0;font-size: 30rpx;" v-if="item.isCertify == 0">&#xe625;</i>
				<i class="iconfont greenIcon" style="margin:0 10rpx 0 0;font-size: 27rpx;" v-else>&#xe625;</i>
				{{item.name}}
				</span>
				<span>{{item.mobile}}</span>
				<span style="color: #00a660;">使用</span>
			</view>
		</view>
		<!-- 暂无数据 -->
		<luanqingEmpty :show="true" text="没有更多数据啦" v-else />	
		</view>
	</view>
</template>

<script>
	import luanqingEmpty from '@/components/luanqing-empty/luanqing-empty';
	import {listCustomerPerson} from "@/api/ec/work/customer/customerPerson";
	import {listCustomerPersonPerson} from "@/api/ec/person/customer/customerPerson";
	export default {
		name:"selectPersonal",
		components:{luanqingEmpty,},
		data() {
			return {
				staffList: [],
				// 查询参数
				queryParams: {
				  pageNum: 1,
				  pageSize: 10,
				  tableName: undefined,
				  tableComment: undefined,
				  params: {
				    findApi: undefined
				  }
				},      
				index:0,
				personalCopy:false, //抄送页面
			};
		},
		onLoad(option) {
			this.index = option.index
			this.personalCopy = option.personalCopy
			this.getList()
		},
		methods:{
			/** 查询员工列表 */
			getList() {
			  if(this.$store.getters.staffInfo.companyId !== 0){
			    listCustomerPerson(this.queryParams).then(response => {
					this.staffList = response.rows;
			    });
			  } else {
			    listCustomerPersonPerson(this.queryParams).then(response => {
			      this.staffList = response.rows;
			    });
			  }
			},    
			/**搜索*/
			handleQuery() {
				this.getList()
			},
			/** 选择使用联系人 */
			selectChange(item){
				if(this.personalCopy){
					let ruleForm = {id:0,sendName:item.name,sendMobile:item.mobile,senderType:1,index:this.index,sendPersonId:item.systemStaffId}
					uni.$emit('copyStaffData',ruleForm)
				}else{
					let ruleForm = {signerName:item.name,signerMobile:item.mobile,index:this.index}
					uni.$emit('staffData',ruleForm)
				}
				uni.navigateBack(1)
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: $uni-bg-color;
	}
	.scroll_view{
		position: absolute;
		top: 110rpx;
		height:80%;
		width: 100%;
		overflow-y: scroll;
	}
.table_view{
	height: 100rpx;
	line-height: 100rpx;
	border-bottom: 1rpx solid #ebeef5;
	padding: 0 20rpx 0 0;
	display: flex;
	justify-content: space-between;
	margin:0 20rpx;
}	
</style>